gtk/dragicon: Don't show until child is set
authorJonas Ådahl <jadahl@gmail.com>
Wed, 25 Nov 2020 14:02:26 +0000 (15:02 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Mon, 7 Dec 2020 08:46:39 +0000 (09:46 +0100)
Showing before the child would result in bogus
gdk_drag_surface_present() with an "empty" (1x1) size. This can easily
be avoided by postponing showing until there is anything to show.

gtk/gtkdragicon.c

index 234867495163b840caa6ef3e6d6df85c7d3b1526..e239090011269f607f423b174557dcdcf0a4cf3e 100644 (file)
@@ -414,7 +414,8 @@ gtk_drag_icon_get_for_drag (GdkDrag *drag)
 
       g_object_set_qdata_full (G_OBJECT (drag), drag_icon_quark, g_object_ref_sink (self), g_object_unref);
 
-      gtk_widget_show (self);
+      if (GTK_DRAG_ICON (self)->child != NULL)
+        gtk_widget_show (self);
     }
 
   return self;
@@ -472,7 +473,10 @@ gtk_drag_icon_set_child (GtkDragIcon *self,
   self->child = child;
 
   if (self->child)
-    gtk_widget_set_parent (self->child, GTK_WIDGET (self));
+    {
+      gtk_widget_set_parent (self->child, GTK_WIDGET (self));
+      gtk_widget_show (GTK_WIDGET (self));
+    }
 
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CHILD]);
 }